<?php
$this->pageHeader = t('PAGE_TITLE', 'gallery');
$this->pageTitle = t('PAGE_TITLE', 'gallery');
$toolbar = new LGToolbar();
$toolbar->buttonAddNew('480', '520', t('PAGE_TITLE_ADDNEW', 'gallery'), t('BTN_ADDNEW'), '', TRUE, app()->controller->id . '/createAlbum');
$toolbar->buttonDelete(t('BTN_DELETE'), '', app()->controller->id . '/deleteAlbum');
$toolbar->buttonRefresh(t('BTN_REFRESH'), '', url(app()->controller->id . '/refresh'));
$this->pageToolbar = $toolbar->mergeToolbar();
$this->breadcrumbs = array('Management', t('LBL_GALLERY', 'gallery'));
//$themeUrl = Yii::app()->theme->baseUrl;
//cs()->registerScriptFile($themeUrl . '/js/jquery.validate.js');
?>
<!-- search-form -->
<div class="search-form" >
    <?php
    $this->renderPartial('_search', array(
	'model' => $model,
    ));
    ?>
</div>

<!-- grid -->
<?php
$this->widget('GridView', array(
    'id' => 'DataGrid',
    'dataProvider' => $model->search(LGHelpers::getPageSize()),
    'summaryText' => LGHelpers::getSummary(),
    //'enableSorting' => false,
    'columns' => array(
	array(
	    'header' => '#',
	    'class' => 'CCheckBoxColumn',
	    'selectableRows' => '2',
	    'id' => 'chkId',
	),
	array(
	    'name' => 'name',
	    //Navigate to action detailRefresh to remove data of "Photo search" session 
	    'value' => 'CHtml::link(CHtml::encode($data->name), url("/gallery/detailRefresh",array("id"=>$data->id)), array("class"=>"bold"))',
	    'type' => 'raw',
	    'sortable' => false,
	),
	array(
	    'name' => 'picture',
	    'value' => 'Html::tag("img", array("src"=> file_exists(MEDIA_FOLDER . DS . "gallery" . DS . $data->picture)? SITE_URL. "/media/gallery/" . $data->picture : SITE_URL. "/media/gallery/no_image.jpg" , 
                "title"=>substr($data->picture, strpos($data->picture, "_") + 1),
                "alt"=>substr($data->picture, strpos($data->picture, "_") + 1), 
                "width"=>"80px", "height"=>"80px"))',
	    'htmlOptions' => array('align' => 'center', 'style' => 'width:100px;'),
	    'type' => 'raw',
	    'sortable' => false,
	),
	array(
	    'htmlOptions' => array('width' => '29px', 'align' => 'center'),
	    'name' => 'status',
	    'value' => 'Html::active($data->id,$data->status, "status")',
	    'type' => 'raw',
	    'sortable' => false,
	),
//        array(
//            'name' => 'display_order',
//            'htmlOptions' => array('width' => '57px', 'align' => 'center'),
//        ),
	array('name' => 'display_order',
	    'value' => 'app()->controller->getHtmlDownButtonForAlbum($data).app()->controller->getHtmlUpButtonForAlbum($data)',
	    'type' => 'raw',
	    'sortable' => false,
	    'htmlOptions' => array(
		'style' => 'width:57px;text-align: center'
	    )),
	array(
	    'name' => 'updated_by',
	    'htmlOptions' => array('align' => 'center', 'width' => '71px'),
	    'sortable' => false,
	),
	array(
	    'name' => 'update_date',
	    'htmlOptions' => array('align' => 'center', 'width' => '99px'),
	    'sortable' => false,
	),
	array(
	    'name' => 'hits',
	    'htmlOptions' => array('align' => 'center', 'width' => '29px'),
	    'sortable' => false,
	),
	array(
	    'name' => 'language',
	    'htmlOptions' => array('align' => 'center', 'width' => '57px'),
	    'value' => 'LGHelpers::getLanguage($data->language)',
	    'sortable' => false,
	),
	array(
	    'name' => 'Photos',
	    'htmlOptions' => array('align' => 'center', 'width' => '50px'),
	    /* Count The number of photos in this album */
	    'value' => 'Photo::model()->countByAttributes(array("album_id" => $data->id))',
	    'sortable' => false,
	)
	,
	array(
	    'name' => 'id',
	    'htmlOptions' => array('align' => 'center', 'width' => '27px'),
	    'sortable' => false,
	),
	array(
	    'header' => t('LBL_ACTION', 'user'),
	    'htmlOptions' => array('align' => 'center', 'width' => '27px'),
	    'headerHtmlOptions' => array('width' => '27px', 'style' => 'text-align:center'),
	    'class' => 'ButtonColumn',
	    'template' => "{updateHasFile}",
	    'buttons' => array(
		'updateHasFile' => array('title' => t('LBL_EDIT_ALBUM', 'gallery'), 'url' => 'url("gallery/updateAlbum/",array("id"=>$data->id))', 'dialog-width' => '480', 'dialog-height' => '520'),
	    )
	),
    ),
));
?>
<?php $this->widget('ext.EUpdateFileDialog.EUpdateFileDialog', array('dialogOptions' => array('resizable' => false))); ?>